﻿@using JsViewEngine
@model JsViewEngine.Demo.Models.MoviesViewModel

@{
    ViewBag.Title = "Render template against local data";
}

<h3>Render template against local data</h3>

@JsTemplates.RenderTemplateBlock("movieTemplate")

<div id="movieList">
@Html.Partial("movieTemplate", Model.Movies)
</div>


@section scripts
{
    @Scripts.Render("~/bundles/jsrender")
    
    <script type="text/javascript">
        var movies = @JsTemplates.ObjectToJson(Model.Movies);

        // Render the template with the movies data and insert
        // the rendered HTML under the "movieList" element
        $( "#movieList" ).html(
            $( "#movieTemplate" ).render( movies )
        );
    </script>
}
